home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-01 | 2.4 KB | 88 lines | [TEXT/MACA] |
- \ rfl writing to offscreen bitmaps
-
- :CLASS bitMap <Super barray
-
- Var BaseAddr
- Int RowBytes
- Rect BndsRect
-
- \ ( n l t r b -- )
- :M PUT: Put: bndsRect Put: RowBytes
- idxbase +base Put: BaseAddr ;M
-
- ;CLASS
-
- :CLASS copier <super grafPort
-
- var destPort \ destination grafPort (abs)
- rect destRect \ destination rectangle
- var offscreen \ hold copy of bitmap address
- int mode \ copy mode
-
- \ **** initialize ****
-
- :M mode: ( n --) put: mode ;M
-
- :M destPort: ( window --) +base put: destPort ;M
-
- :M destRect: ( l t r b --) put: destRect ;M
-
- \ **** creation ****
-
- :M open: (abs) call openPort ;M
-
- :M rowBytes: ( -- n) size: destRect drop 15 + 4 >> 1 << ;M
-
- :M new: { \ myBitMap rows -- }
- open: self
- rowBytes: self -> rows \ calc rowbytes
- rows size: destRect swap drop * \ calc size of bitmap
- heap> bitMap -> myBitMap \ create bitmap on heap
- rows get: destRect put: myBitMap \ init bitmap
- myBitMap put: offScreen \ store pointer for disposing
- pushPort set: self \ set bitmap to grafport
- myBitMap +base call setPortBits
- get: destRect ^base 16 + put: rect
- popPort ;M
-
- :M close: (abs) call closePort dispose: offscreen ;M
-
- \ *** manipulation ****
-
- :M draw: ^base 2+ +base obj: destPort 2+
- (abs) 16 + abs: destRect
- int: mode
- get: destPort -base 24 + @ call copyBits ;M \ draw in visrgn of destPort
-
- :M save: obj: destPort 2+ ^base 2+ +base
- abs: destRect (abs) 16 +
- word0 get: destPort -base 24 + @ call copyBits ;M \ write over previous
-
- :M offset: ( dx dy -- ) offset: destRect ;M
-
- :M moveTo: { x y -- } x getTopX: destRect - y getTopY: destRect -
- offset: destRect ;M
-
- :M clear: clear: [ obj: offScreen ] ;M
-
- ;CLASS
-
- \ example
- \ copier bob
- \ 30 30 130 130 destrect: bob \ getrect: myPort destrect: bob
- \ fwind destport: bob
- \ new: bob
- \ set: fwind
- \ to draw into offscreen bitmap: 'set: bob' then all output to
- \ screen goes offscreen. To draw bitmap to desport, 'draw: bob'
- \ to save what is in destrect in destport, 'save: bob'.
-
- \ sequence should be
- \ destrect, destport, mode?
- \ new: which creates bitmap, stores into grafport, and putrect
-
- \ Any rectangular area within a window could be the destrect, even the
- \ port.rect. save: copies the window into the offscreen bitmap
- \ and draw: will return it to the window.
- \ Alternatively, one could set: the copier object, draw into it,
- \ then draw:...this will draw into the visrgn of the dest window.